import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


class Node1 {
    int x;
    int y;

    public Node1 (int x,int y) {
        this.x = x;
        this.y = y;
    }
}

public class HJ43 {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        while(s.hasNext()) {
            String str1 = s.nextLine();
            String[] strs = str1.split(" ");
            int row = Integer.parseInt(strs[0]);
            int col = Integer.parseInt(strs[1]);
            int[][] arr = new int[row][col];
            for(int i = 0; i < row; i++) {
                String str2 = s.nextLine();
                String[] strs1 = str2.split(" ");
                for(int j = 0; j < col; j++) {
                    arr[i][j] = Integer.parseInt(strs1[j]);
                }
            }
            List<Node1> path = new ArrayList<>();
            List<Node1> minPath = new ArrayList<>();
            int[][] book = new int[row][col];
            getMinPath(arr,row,col,0,0,book,path,minPath);
            for(Node1 node : minPath) {
                System.out.println("(" +node.x +"," +node.y +")");
            }
        }
    }
    public static void getMinPath(int[][] arr,int row,int col,int x,int y,int[][] book,List<Node1> path,List<Node1> minPath) {
        if(x < 0 || x >= row || y < 0 || y >= col || book[x][y] == 1 || arr[x][y] == 1) return;
        path.add(new Node1(x,y));
        book[x][y] = 1;
        if(x == row - 1 && y == col - 1) {
            if(minPath.isEmpty() || path.size() < minPath.size()) {
                minPath.clear();
                for(Node1 node : path) {
                    minPath.add(node);
                }
            }
        }
        getMinPath(arr,row,col,x + 1,y,book,path,minPath);
        getMinPath(arr,row,col,x - 1,y,book,path,minPath);
        getMinPath(arr,row,col,x,y + 1,book,path,minPath);
        getMinPath(arr,row,col,x,y - 1,book,path,minPath);
        path.remove(path.size() - 1);
        book[x][y] = 0;
    }
}
